package de.baumann.browser.activitys.hash

import android.annotation.SuppressLint
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import de.baumann.browser.R
import de.baumann.browser.adapter.OdinRecordAdapter
import de.baumann.browser.api.net.vo.OdinValue
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IOdinRecordView
import de.baumann.browser.present.OdinValuePresenter
import kotlinx.android.synthetic.main.activity_odin_record.*
import kotlinx.android.synthetic.main.head_odin_record.*
import kotlinx.android.synthetic.main.include_tool_bar.*

/**
 * @author:
 * @date:2018/12/10 17:06
 * @discription:ODIN值
 */
@Deprecated("废弃")
class OdinValueActivity : BaseOdinActivity<IOdinRecordView, OdinValuePresenter>(), IOdinRecordView {

    private var mHeadView: View? = null
    private lateinit var odinRecordAdapter: OdinRecordAdapter

    override fun getTitleText(): String {
        return getString(R.string.odin_value)
    }

    override fun getLayout(): Int {
        return R.layout.activity_odin_record
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)
        mHeadView = LayoutInflater.from(mContext).inflate(R.layout.head_odin_record, null, false)
        rvOdinRecord.layoutManager = LinearLayoutManager(mContext)
        odinRecordAdapter = OdinRecordAdapter(R.layout.recycler_item_odin_record)
        odinRecordAdapter.addHeaderView(mHeadView)
        rvOdinRecord.adapter = odinRecordAdapter
    }

    override fun initData() {
        presenter.getOdinRecord()
        setTotalValue(intent.getStringExtra("odin"))
    }

    override fun createPresenter(): OdinValuePresenter? {
        return OdinValuePresenter()
    }

    override fun createView(): IOdinRecordView? {
        return this
    }

    @SuppressLint("SetTextI18n")
    fun setTotalValue(totalValue: String) {
        mHeadView!!.findViewById<TextView>(R.id.tvTotalValue).text = totalValue
    }

    override fun setOdinList(odinList: List<OdinValue>) {
        odinRecordAdapter.setNewData(odinList)
    }

    override val startPage: Int
        get() = 0

}
